package artifacts;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import javax.swing.Timer;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import c4jason.*;
import jason.architecture.*;
import jason.asSemantics.*;
import jason.asSyntax.*;

import java.util.*;
import java.io.*;

import c4jason.CAgentArch;

import cartago.*;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.pdf.PdfWriter;


public class IAARArt extends Artifact {
	
	public DefaultListModel model = new DefaultListModel();
	private String path = "D:/Archivos";
	public Timer timer;
	private ObsProperty prop;
	private boolean checking;

	void init(){
	
		defineObsProperty("documentProcessed",-1);
		defineObsProperty("documentDescriptors",-1,"");
		defineObsProperty("documentReady",-1,"");
		defineObsProperty("storageOK",-1);
	}
	
	@OPERATION void readDocuments(String document_id)
	{
		ObsProperty prop = getObsProperty("documentProcessed");
		prop.updateValue("1");	
		
	}
	
	@OPERATION void candidateDescriptor(String document_id)
	{
		ObsProperty prop = getObsProperty("documentDescriptors");
		prop.updateValue(0,document_id);	
		prop.updateValue(1,"uno-dos-tres");	
		
	}
	
	@OPERATION void getDocument(String document, String type_of_access)
	{
		ObsProperty prop = getObsProperty("documentReady");
		//Aca tendria que buscar el documento en el km system, leerlo y obtener el formato
		prop.updateValue(0,"contenido del documento");
		if(type_of_access.equals("1"))
			prop.updateValue(1,"pdf");
		else
			prop.updateValue(1,"txt");
	}
	
	@OPERATION void storageDocument(String document_name, String document_content)
	{
		//Guarda el documento - CARLOS
		
		ObsProperty prop = getObsProperty("storageOK");
		prop.updateValue(0,document_name);
	}
	
}

